package com.hiultra.archive.controller;

import com.hiultra.archive.domain.ArcEquipment;
import com.hiultra.archive.service.IArcEquipmentService;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.core.page.TableDataInfo;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 设备管理Controller
 * 
 * @author ls
 * @date 2022-07-28
 */
@Api(tags="设备管理Controller")
@RestController
@RequestMapping("/base/equipment")
public class ArcEquipmentController extends BaseController
{
    @Autowired
    private IArcEquipmentService arcEquipmentService;

    /**
     * 查询设备管理列表
     */
    @ApiOperation(value = "导出阈值设置列表", notes = "导出阈值设置列表")
    @PreAuthorize("@ss.hasPermi('base:equipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArcEquipment arcEquipment)
    {
        startPage();
        List<ArcEquipment> list = arcEquipmentService.selectArcEquipmentList(arcEquipment);
        return getDataTable(list);
    }

    /**
     * 导出设备管理列表
     */
    @ApiOperation(value = "导出设备管理列表", notes = "导出设备管理列表")
    @PreAuthorize("@ss.hasPermi('base:equipment:export')")
    @Log(title = "设备管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArcEquipment arcEquipment)
    {
        List<ArcEquipment> list = arcEquipmentService.selectArcEquipmentList(arcEquipment);
        ExcelUtil<ArcEquipment> util = new ExcelUtil<ArcEquipment>(ArcEquipment.class);
        util.exportExcel(response, list, "设备管理数据");
    }

    /**
     * 获取设备管理详细信息
     */
    @ApiOperation(value = "获取设备管理详细信息", notes = "获取设备管理详细信息")
    @PreAuthorize("@ss.hasPermi('base:equipment:query')")
    @GetMapping(value = "/{equipmentId}")
    public AjaxResult getInfo(@PathVariable("equipmentId") Long equipmentId)
    {
        return AjaxResult.success(arcEquipmentService.selectArcEquipmentByEquipmentId(equipmentId));
    }

    /**
     * 新增设备管理
     */
    @ApiOperation(value = "新增设备管理", notes = "新增设备管理")
    @PreAuthorize("@ss.hasPermi('base:equipment:add')")
    @Log(title = "设备管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArcEquipment arcEquipment)
    {
        return toAjax(arcEquipmentService.insertArcEquipment(arcEquipment));
    }

    /**
     * 修改设备管理
     */
    @ApiOperation(value = "修改设备管理", notes = "修改设备管理")
    @PreAuthorize("@ss.hasPermi('base:equipment:edit')")
    @Log(title = "设备管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArcEquipment arcEquipment)
    {
        return toAjax(arcEquipmentService.updateArcEquipment(arcEquipment));
    }

    /**
     * 删除设备管理
     */
    @ApiOperation(value = "删除设备管理", notes = "删除设备管理")
    @PreAuthorize("@ss.hasPermi('base:equipment:remove')")
    @Log(title = "设备管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentIds}")
    public AjaxResult remove(@PathVariable Long[] equipmentIds)
    {
        return toAjax(arcEquipmentService.deleteArcEquipmentByEquipmentIds(equipmentIds));
    }
}
